package edu.brandeis.cs.steele.wn;

import java.io.File;
import java.util.logging.Logger;

import edu.brandeis.cs.steele.exceptions.PronunciationNotFindException;
import edu.brandeis.cs.steele.util.BubblerLogger;

/**
 * 
 * @author Sergiy Doroshenko webserg@gmail.com
 */
public class Pronunciation {
    static Logger logger = BubblerLogger.getLogger();
    private File file;
    private MP3 mp3;
    //String filename = ".//dbMP3//search.mp3";
    public Pronunciation(IndexWord wordIdx) throws PronunciationNotFindException{
        //StringBuilder path = new StringBuilder(".//dbMP3//");
        StringBuilder path = new StringBuilder("c://english//MP3Dictionary//");
        if(wordIdx.pos == POS.NOUN) path.append("noun//");
        //else if(wordIdx.pos == POS.VERB) path.append("verb//");
        path.append(wordIdx.getLemma());
        path.append(".mp3");
        File dest = new File(path.toString());
        if(!dest.exists()) throw new PronunciationNotFindException(dest.getAbsolutePath());
        this.file = dest;
        this.mp3 = new MP3(file);
    }
    
    public void play(){
        mp3.play();
    }
}
